/**   
 * @Title: ShiyixuanwuPlayStyle.java 
 * @Package com.esun.share.po 
 * @Description: 记录十一选五玩法文件
 * @author Miko baoz@500wan.com   
 * @date 2011-1-15 下午04:33:54  
 */
package com.esun.rabbit2.viewer.mainact.lotteryhallact.shiyixuanwu.rabbittrunk;

import java.util.ArrayList;
import java.util.Hashtable;

import com.esun.ui.R;
import com.esun.util.log.EDebug;

import android.view.View;
import android.widget.Button;

/**
 * @ClassName: ShiyixuanwuPlayStyle
 * @Description: TODO(记录十一选五玩法)
 * @author Miko baoz@500wan.com
 * @date 2011-1-15 下午04:33:54
 * 
 */
public class ShiyixuanwuPlayStyle {

	private ShiyixuanwuPlayStyle() {
		tableInit();
	}

	private static ShiyixuanwuPlayStyle playStyle = null;

	public static ShiyixuanwuPlayStyle getPlayStyle() {

		if (playStyle == null) {

			return playStyle = new ShiyixuanwuPlayStyle();

		} else {

			return playStyle;
		}
	}

	private Hashtable<Integer, Integer[]> tbStyleDisable = new Hashtable<Integer, Integer[]>();
	private Hashtable<Integer, Integer[]> tbDetailDisable = new Hashtable<Integer, Integer[]>();

	private void tableInit() {

		int[] style = {
						1,
						2,
						3,
						4,
						5,
						6,
						7,
						8 };
		int[] detail = {
						1,
						2,
						3 };

		Integer[] detailToStyle1 = {
									1,
									3 };
		Integer[] detailToStyle2 = {};
		Integer[] detailToStyle3 = {};
		Integer[] detailToStyle = {
									2,
									3 };

		Integer[] styleToDetail1 = { 1 };
		Integer[] styleToDetail2 = {
									4,
									5,
									6,
									7,
									8 };
		Integer[] styleToDetail3 = {
									1,
									4,
									5,
									6,
									7,
									8 };

		tbStyleDisable.put(detail[0], styleToDetail1);
		tbStyleDisable.put(detail[1], styleToDetail2);
		tbStyleDisable.put(detail[2], styleToDetail3);

		for (int i = 0; i < style.length; i++) {
			if (i + 1 == 1) {
				tbDetailDisable.put(i + 1, detailToStyle1);
			} else if (i + 1 == 2) {
				tbDetailDisable.put(i + 1, detailToStyle2);
			} else if (i + 1 == 3) {
				tbDetailDisable.put(i + 1, detailToStyle3);
			} else {
				tbDetailDisable.put(i + 1, detailToStyle);
			}
		}
	}

	public Hashtable<Integer, Integer[]> getTbStyleDisable() {
		return tbStyleDisable;
	}

	public Hashtable<Integer, Integer[]> getTbDetailDisable() {
		return tbDetailDisable;
	}

	// 玩法
	private int style = 5;
	// 投注方式
	private int detail = 1;

	// 玩法禁用序号
	private Integer[] styleDisable = {
										0,
										0,
										0,
										0,
										0,
										0,
										0,
										0 };

	// 方式禁用序号
	private Integer[] detailDisable = {
										0,
										0,
										0 };

	// 玩法名称
	private String[] styleTxt = {
									"选玩法",
									"选一",
									"选二",
									"选三",
									"任选四",
									"任选五",
									"任选六",
									"任选七",
									"任选八" };

	// 投注方式名称
	private String[] detailTxt = {
									"选投法",
									"任选",
									"前直选",
									"前组选" };

	// 玩法的按钮
	private ArrayList<Button> alBtnStyle;

	// 方式按钮
	private ArrayList<Button> alBtnDetail;

	// 方式显示临时字段
	private String detailTemp = DataShare.NULLMARK;

	// 玩法提示
	private String playTip = DataShare.NULLMARK;

	public int getStyle() {
		return style;
	}

	public void setStyle(int style) {
		this.style = style;
	}

	public int getDetail() {
		return detail;
	}

	public void setDetail(int detail) {
		this.detail = detail;
	}

	public String getStyleTxt() {
		return styleTxt[style];
	}

	public String getDetailTxt() {
		return detailTxt[detail];
	}

	public ArrayList<Button> getAlBtnStyle() {

		EDebug.o(this, String.valueOf(alBtnStyle.size()) + "!!!!!!!!!");

		return alBtnStyle;

	}

	public ArrayList<Button> getAlBtnDetail() {
		EDebug.o(this, String.valueOf(alBtnDetail.size()) + "!!!!!!!!!---");
		return alBtnDetail;
	}

	public Integer[] getStyleDisable() {
		return styleDisable;
	}

	public void setStyleDisable(Integer[] styleDisable) {
		this.styleDisable = styleDisable;
	}

	public Integer[] getDetailDisable() {
		return detailDisable;
	}

	public void setDetailDisable(Integer[] detailDisable) {
		this.detailDisable = detailDisable;
	}

	public void setAlBtnStyle(ArrayList<Button> alBtnStyle) {
		this.alBtnStyle = alBtnStyle;
	}

	public void setAlBtnDetail(ArrayList<Button> alBtnDetail) {
		this.alBtnDetail = alBtnDetail;
	}

	public String getDetailTemp() {
		return detailTemp;
	}

	public void setDetailTemp(String detailTemp) {
		this.detailTemp = detailTemp;
	}

	/**
	 * @Title: resetAllButtons
	 * @Description: TODO(重置所有按钮可用)
	 * @return void
	 */
	public void resetAllButtons() {
		for (int i = 0; i < alBtnDetail.size(); i++) {
			alBtnDetail.get(i).setVisibility(View.VISIBLE);
		}
	}

	/**
	 * @Title: setDetailBtnDisabled
	 * @Description: TODO(设置方式按钮不可用)
	 * @param @param loc 所按的玩法按钮位置
	 * @return void
	 */
	public void setDetailBtnDisabled(int loc) {

		Integer[] detailDisable = null;

		ArrayList<Button> alRestButtons = new ArrayList<Button>();

		detailDisable = ShiyixuanwuPlayStyle.getPlayStyle().getTbDetailDisable().get(loc);

		ShiyixuanwuPlayStyle.getPlayStyle().setDetailDisable(detailDisable);

		int count = detailDisable.length;

		for (int i = 0; i < count; i++) {
			EDebug.o(this, "Detail Disabled include : " + String.valueOf(detailDisable[i]));

			EDebug.o(this, "AlBtnDetail size is : " + String.valueOf(ShiyixuanwuPlayStyle.getPlayStyle().getAlBtnDetail().size()));
			if (detailDisable[i] != 0 && detailDisable[i] != null) {
				ShiyixuanwuPlayStyle.getPlayStyle().getAlBtnDetail().get((detailDisable[i] - 1)).setVisibility(View.GONE);
			}
		}

		for (int i = 0; i < alBtnDetail.size(); i++) {

			Button btn = alBtnDetail.get(i);

			if (btn.getVisibility() != View.GONE) {
				alRestButtons.add(btn);
			}

		}

		int ii = alRestButtons.size();
		if (ii == 1) {
			 alRestButtons.get(0).setBackgroundResource(R.drawable.shiyixuanwu_alert_button_onlyone_style);
			if (style != 1) {
				alRestButtons.get(0).setText(getPlayStyle().getStyleTxt());
			} else {
				alRestButtons.get(0).setText("前一直选");
			}
		} else if (ii == 2) {
			 alRestButtons.get(0).setBackgroundResource(R.drawable.shiyixuanwu_alert_button_top_style);
			alRestButtons.get(0).setText("前二直选（中奖奖金130元）");
			 alRestButtons.get(1).setBackgroundResource(R.drawable.shiyixuanwu_alert_button_bottom_style);
			alRestButtons.get(1).setText("前二组选（中奖奖金65元）");
		} else if (ii == 3) {
			 alRestButtons.get(0).setBackgroundResource(R.drawable.shiyixuanwu_alert_button_top_style);
			if (style == 2) {
				alRestButtons.get(0).setText("任选二（中奖奖金6元）");
			} else {
				alRestButtons.get(0).setText("任选三（中奖奖金19元）");
			}
			 alRestButtons.get(1).setBackgroundResource(R.drawable.shiyixuanwu_alert_buttons_style);
			if (style == 2) {
				alRestButtons.get(1).setText(" 前二直选（中奖奖金130元）");
			} else {
				alRestButtons.get(1).setText(" 前三直选（中奖奖金1170元）");
			}
			 alRestButtons.get(2).setBackgroundResource(R.drawable.shiyixuanwu_alert_button_bottom_style);
			if (style == 2) {
				alRestButtons.get(2).setText("前二组选（中奖奖金65元）");
			} else {
				alRestButtons.get(2).setText("前三组选（中奖奖金195元）");
			}
		}
	}

	/**
	 * @Title: setStyleBtnDisabled
	 * @Description: TODO(设置玩法按钮不可用)
	 * @param @param loc 所按的玩法按钮位置
	 * @return void
	 */
	public void setStyleBtnDisabled(int loc) {

		Integer[] styleDisabled = null;

		styleDisabled = ShiyixuanwuPlayStyle.getPlayStyle().getTbStyleDisable().get(loc);

		ShiyixuanwuPlayStyle.getPlayStyle().setStyleDisable(styleDisabled);

		for (int i = 0; i < styleDisabled.length; i++) {
			EDebug.o(this, "Style Disabled include : " + String.valueOf(styleDisabled[i]));

			EDebug.o(this, "AlBtnStyle size is : " + String.valueOf(ShiyixuanwuPlayStyle.getPlayStyle().getAlBtnStyle().size()));
			if (styleDisabled[i] != 0 && styleDisabled[i] != null) {
				ShiyixuanwuPlayStyle.getPlayStyle().getAlBtnStyle().get((styleDisabled[i] - 1)).setEnabled(false);
			}
		}
	}

	public String getButtonTxt(int style, int detail) {
		if (style == 1) {
			playTip = "玩法提示：从11个号码中任选1个号码。奖金13元。";
			return "前一直选";
		} else if (style == 2) {
			if (detail == 1) {
				playTip = "玩法提示：从11个号码中任选2个号码。奖金6元。";
				return "任选二";
			} else if (detail == 2) {
				playTip = "玩法提示：每行各选1个号码。奖金130元。";
				return "前二直选";
			} else if (detail == 3) {
				playTip = "玩法提示：任意2个号码组成1注有效注。奖金65元。";
				return "前二组选";
			}
		} else if (style == 3) {
			if (detail == 1) {
				playTip = "玩法提示：从11个号码中任选3个号码。奖金19元。 ";
				return "任选三";
			} else if (detail == 2) {
				playTip = "玩法提示：每行各选1个号码。奖金1170元。";
				return "前三直选";
			} else if (detail == 3) {
				playTip = "玩法提示：任意3个号码组成1注有效注。奖金195元。";
				return "前三组选";
			}
		} else if (style == 4) {
			playTip = "玩法提示：从11个号码中任选4个号码。奖金78元。";
			return "任选四";
		} else if (style == 5) {
			playTip = "玩法提示：从11个号码中任选5个号码。奖金540元。";
			return "任选五";
		} else if (style == 6) {
			playTip = "玩法提示：从11个号码中任选6个号码。奖金90元。";
			return "任选六";
		} else if (style == 7) {
			playTip = "玩法提示：从11个号码中任选7个号码。奖金26元。";
			return "任选七";
		} else if (style == 8) {
			playTip = "玩法提示：从11个号码中任选8个号码。奖金9元。";
			return "任选八";
		}
		return "";
	}
	
	public String getTip(){
		return playTip;
	}
}
